#ifndef __OANIMATION_CACHE_H__
#define __OANIMATION_CACHE_H__

#include "misc/oXmlItemCache.h"
#include "model/oModelDef.h"

class oClipDef;
class oFrame;

/** @brief Frame action define. Frame action is a sequence of images that show in a row. */
class oDLL oFrameActionDef: public CCObject
{
public:
	string textureFile;
	float duration;
	ptr_vector<CCRect> rects;
	virtual oFrame* toAction();
	string toXml();
	static oFrameActionDef* create();
protected:
	oFrameActionDef();
};

/** @brief Load frame animations from ".frame" files and cache them. */
class oDLL oAnimationCache: public oXmlItemCache<oFrameActionDef>
{
public:
	/** Singleton method as oAnimationCache::sharedCache(). */
	SHARED_CACHE_FUNC(oAnimationCache)
protected:
	oAnimationCache(){}
	virtual void beforeParse( const char* filename );
	virtual void afterParse( const char* filename );
	virtual void textHandler( void *ctx, const char *s, int len );
	virtual void startElement( void *ctx, const char *name, const char **atts );
	virtual void endElement( void *ctx, const char *name );
};

#define oSharedAnimationCache oAnimationCache::sharedCache()

#endif
